/**
 * Copyright (c) 2010 Sense Tecnic Systems Inc.
 */
package com.testcase.vincentApp;

import com.testcase.R;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

/**
 * Activity for the preference page in this application.
 * 
 * @author Vincent Tsao
 */
public class Preferences extends PreferenceActivity
{
	private SharedPreferences preferences;
	private PreferenceChangedHandler preferenceChangedHandler;

	@Override
	protected void onCreate (Bundle savedInstanceState)
	{
		super.onCreate (savedInstanceState);

		// load preferences layout
		addPreferencesFromResource (R.layout.vincent_preferences);

		// set variables used throughout the app
		// preferences = getPreferenceScreen ().getSharedPreferences ();
		preferences = PreferenceManager.getDefaultSharedPreferences (this);
		preferenceChangedHandler = new PreferenceChangedHandler (getResources (), SensorManager.getSensorManager ());
	}

	@Override
	protected void onStart ()
	{
		super.onStart ();
	}

	@Override
	protected void onRestart ()
	{
		super.onRestart ();
	}

	@Override
	protected void onResume ()
	{
		super.onResume ();

		preferences.registerOnSharedPreferenceChangeListener (preferenceChangedHandler);
	}

	@Override
	protected void onPause ()
	{
		super.onPause ();

		preferences.unregisterOnSharedPreferenceChangeListener (preferenceChangedHandler);
	}

	@Override
	protected void onStop ()
	{
		super.onStop ();
	}

	@Override
	protected void onDestroy ()
	{
		super.onDestroy ();

		preferences.unregisterOnSharedPreferenceChangeListener (preferenceChangedHandler);
	}
}
